<?php
/**
 * Created by : PhpStorm
 * User: Shane
 * Date: 2023-05-26
 * Time: 15:35
 */

namespace app\api\controller\client;


use app\common\controller\Api;
use app\common\model\Message as MessageModel;
class Message extends Api
{
    /**
     * 获取我的个人消息
     */
    public function getMyMessage(){
        $page = !$this->request->param('page') ? 1 : $this->request->param('page');//页
        $list=MessageModel::field("id,name,logo,describe,address,lon,lat,door_image,images,start_time,end_time")
            ->where(["status"=>1])
            ->paginate(10, '', ['page' => $page, 'list_rows' => 10]);
        $this->success("成功",$list);
    }
    /**
     * 消息标记为已读
     */
    public function readMessage(){
        $id=$this->request->param("id");
        if(!is_numeric($id)) $this->error('提交失败：参数非法！');
        $res=MessageModel::update(["is_red"=>1,""=>date("Y-m-d H:i:s")],["id"=>$id]);
        if($res){
            $this->success("成功");
        }else{
            $this->error("失败");
        }
    }
}